// 获取环境变量的值
const project_name = 'XLYJ';
const tmp = {"appid": "APPID", "secret": "SECRET"}

const config = get_sys_config();

function get_sys_config() {
    // let appid = process.env[`${project_name}_${tmp.appid}`];
    // let secret = process.env[`${project_name}_${tmp.secret}`];
    let minio = get_minio_config();
    return { minio };
}

// 获取MinIO配置
function get_minio_config() {
    let endPoint = process.env[`${project_name}_MINIO_ENDPOINT`];
    let port = process.env[`${project_name}_MINIO_PORT`];
    let useSSL = process.env[`${project_name}_MINIO_USESSL`];
    let accessKey = process.env[`${project_name}_MINIO_AKEY`];
    let secretKey = process.env[`${project_name}_MINIO_SKEY`];
    if (!endPoint || !port || !useSSL || !accessKey || !secretKey) {
        console.log('读取不到系统环境变量:');
        console.log(`    - ${project_name}_MINIO_ENDPOINT`);
        console.log(`    - ${project_name}_MINIO_PORT`);
        console.log(`    - ${project_name}_MINIO_USESSL`);
        console.log(`    - ${project_name}_MINIO_AKEY`);
        console.log(`    - ${project_name}_MINIO_SKEY`);
        process.exit(1);
    }
    return { endPoint, port, useSSL, accessKey, secretKey };
}

module.exports = config;